package com.study.springboot;

import java.io.File;
import javax.servlet.ServletException;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.startup.Tomcat.FixContextListener;

/**
 * @author lupengwei 2021/7/2 14:03
 */
public class SpringApplication {
    
    public static void run() throws LifecycleException, ServletException {
        // 创建 tomcat
        Tomcat tomcat = new Tomcat();
        tomcat.setPort(8080);
    
        String docBase = "src/main/webapp/";
        tomcat.addWebapp("/", new File(docBase).getAbsolutePath());
        
        // 启动 Tomcat
        tomcat.start();
        tomcat.getServer().await();
    }
}
